let Cookies = null;
(function() {
    //设置函数封装
    function setCookies(k, v, day) {
        let d = new Date();
        d.setDate(d.getDate() + day);
        let c = `${k}=${v};expires=${d};path=/`;
        // console.log(c);
        document.cookie = c;
    }

    //读取函数封装
    function getCookies(k) {
        let cookies = document.cookie;
        let reg = /([^;=&\s]+)[=\s]*([^;\s]*)/g;
        let obj = {};
        while (reg.exec(cookies)) {
            obj[RegExp.$1] = RegExp.$2;
        }
        // console.log(obj);
        return obj[k];
    }

    //删除函数封装
    function removeCookies(k) {
        setCookies(k, '', -100);
    }

    Cookies = {
        remove: removeCookies,
        set: setCookies,
        get: getCookies
    };
})();